package com.zx.kitchen.index.common.mvp.presenter;

import android.content.Context;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.zx.kitchen.index.common.entity.GoodsReportBeans;
import com.zx.kitchen.index.common.mvp.OnResultListener;
import com.zx.kitchen.index.common.mvp.model.BusinessGoodsReportModelImpl;
import com.zx.kitchen.index.common.mvp.view.GoodsReportView;

/**
 * Created by Administrator on 2017/3/20.
 */

public class BusinessGoodsReportPersenter implements OnResultListener {
    private BusinessGoodsReportModelImpl businessGoodsReportModel;
    private GoodsReportView goodsReportView;
    private Context context;


    public BusinessGoodsReportPersenter(Context context, GoodsReportView goodsReportView) {
        this.context = context;
        this.goodsReportView = goodsReportView;
        businessGoodsReportModel = new BusinessGoodsReportModelImpl();
    }

    public void getFromNet(String start_time, String end_time) {
        businessGoodsReportModel.getFromNet(0, context, start_time, end_time, this, null);
    }


    @Override
    public void onSuccess(int requestCode, String str) {
        GoodsReportBeans goodsReportBeans = JSON.parseObject(str, new TypeReference<GoodsReportBeans>() {
        });
        goodsReportView.onSuccess(goodsReportBeans);
    }

    @Override
    public void onFailure(int requestCode, String str) {
        goodsReportView.onFail(str);
    }
}
